<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>天气案例</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <!-- 准备好一个容器 -->
    <div id="root">
        <h1>今天天气很{{ getIsHot }}</h1>
        <!-- 绑定事件的时候：@xxx="yyy" yyy可以写一些简单的语句 -->
        <!-- <button @click="isHot = !isHot">切换</button> -->
        <button @click="changeWeather">切换</button>

        <!-- vm身上没有window, 需要在data里面声明 -->
        <button @click="window.alert(1)">切换</button>
    </div>
</body>

<script type="text/javascript">
    Vue.config.productionTip = false;   // 阻止vue 在启动时生成生产提示

    new Vue({
        el: "#root",
        data: {
            isHot: true,
            window
        },
        computed: {
            getIsHot() {
                return this.isHot ? "炎热" : "凉爽"
            }
        },
        methods: {
            changeWeather() {
                this.isHot = !this.isHot
            }
        },
    })
</script>
</html>